<script type="text/javascript" src="https://irds.alipay.com/merchant/merchant.js"></script>
<script type="text/javascript">
    $(function() {
        $(".mode_top ul li a").each(function(index, item) {
            $(item).click(function() {
                $('.mode_top ul li').removeClass('modeON');
                $(this).parent().addClass('modeON');
                $('.paymode .pm').hide();
                $('.paymode .pm').eq(index).show();
                return false;
            });

        });
        $("#paypaylink").click(function() {
            $(this).text('正在提交支付...');
            $(this).unbind('click');
            $("#paypal_form").submit();
            return false;
        });
        $("#alipaylink").click(function() {
            $(this).text('正在提交支付...');
            $(this).unbind('click');
            $('#chinapay_form').submit();
            return false;
        });
        $('#cardlink').click(function() {

            if (parseFloat($('#cardusmoney').text().replace('$', '')) < 1) {
                alert('支付宝国际信用卡最低支付1美元,请次交易为' + $('#cardusmoney').text() + '。\n请选择别的支付方式');
                return false;
            }
            if ($('#vcard').val() == '') {
                alert('请选择您的卡片类型');
                return false;
            }
            $(this).text('正在提交支付...');
            $(this).unbind('click');
            $('#card_form').submit();
            return false;
        });
        $('#usemoney').change(function() {
            if ($(this).attr("checked")) {
                $(".SJzhifu").css('visibility', 'visible');
                $('#allpay,#allpay2').hide();
                $('#partpay,#partpay2').show();
            } else {
                $(".SJzhifu").css('visibility', 'hidden');
                $('#allpay,#allpay2').show();
                $('#partpay,#partpay2').hide();
            }
            $('.useAccount').val($(this).is(':checked'));
        });
        $('#payall').click(function() {
            $(this).text('正在提交支付...');
            $(this).unbind('click');
            $('#f_payall').submit();
            return false;
        });
        $('#card li a').click(function() {
            $('#card li').removeClass('bankON');
            $(this).parent().addClass('bankON');
            $('#vcard').val($(this).attr('data'));
            return false;
        });
        var jsreturn = window["alipay-merchant-result"];
        $("#jsreturn").val(jsreturn);
    });
</script>
<div class="center">
    <div class="pay">

        <div class="payname">
            <h1>您正在为<?php echo $this->name; ?>付款......</h1>
        </div>
        <div class="payinfo">
            <div class="jiner">
                <div class="Payts">
                    <h2><?php echo $this->name; ?>已提交，请尽快付款！</h2><p>还差一步，请立即支付！</p>
                </div>
                <div class="Paybh" <?php if ($this->type != 1){ echo "style='height:100px;'"; }?>>
                    <ul>
                        <li>您的<?php echo $this->name; ?>号：<em><?php echo $this->billNo ?></em></li>
                        <li>应付金额：<strong><?php echo $this->money; ?></strong>元</li>
                        <?php if ($this->type != 1){ ?><li><a class="indexa" style='font-size: 18px;font-weight: 900;font-family: "Microsoft Yahei","simhei";' href="/campaign/valentine" target="_blank">充值送现金火爆全球，猛击详情</a></li><?php } ?>
                    </ul>
                    <?php if ($this->type == 3) { ?>
                        <p><a href="/member/waybill">查看运单状态</a><a href="/member/mystore">返回我的仓库</a></p>
            <?php } ?>
                </div>
            </div>
<?php if ($this->type != 1 && $this->accountMoney > 0) { ?>
                <div class="yuer">
                    <ul>
                        <li>账户余额：<?php echo $this->accountMoney ?>元</li>
                        <?php if ($this->accountMoney < $this->money) { ?>
                            <li><label><input id="usemoney" name="usemoney" type="checkbox" value="yes" />使用余额付款</label></li>
                    <?php } ?>
                    </ul>
    <?php if ($this->accountMoney < $this->money) { ?>
                        <div class="SJzhifu" style="visibility:hidden">
                            完成本次付款您还需支付：<em>￥<?php echo number_format($this->money - $this->accountMoney, 2) ?></em>元
                        </div>
    <?php } else { ?>
                        <div class="qrzhifu">
                            <form method="post" id="f_payall" action="/pay/paid">
                                <div class="payenter">
                                    <a id="payall" href="javascript:void(0)">全部余额支付</a>
                                </div>

        <?= $this->formHidden('type', $this->type) ?>
                        <?= $this->formHidden('id', $this->id) ?>
                            </form>
                        </div>
                <?php } ?>
                </div>
<?php } ?>
        </div>        
        <div class="paymode">
            <div class="mode_top">
                <label>请选择支付方式：</label>
                <ul>
                    <li class="modeON"><a href="#">PayPal支付</a></li>
                    <li><a href="#">支付宝支付</a></li>
                    <li><a href="#">国际信用卡</a></li>
                </ul>
            </div>

            <div class="paypal pm">
                <div class="modeTS">
                    <h2>您当前选择的支付方式是PayPal</h2>
                </div>
                <div class="modesm">
                    <div class="modelogo">
                        PayPal                      
                    </div>
                    <div class="modeinfo">
                        <h3>PayPal接受各种外币，您的实际支付金额系统将加收外币汇兑手续费！</h3>
                        <p>实际支付金额 = 目标金额 + 目标金额 * 汇兑手续费3% + 0.3 USD (每笔)</p>
                    </div>
                </div>
                <div class="zhifuNUM">
                    <ul>
                        <li>PayPal汇兑手续费为：3% + 0.3 USD (每笔)<i><a href="http://help.uuch.com/?p=325" target="_blank">什么是汇兑手续费？</a></i></li>
                        <li>当前汇率：<?php echo $this->rate ?> 人民币/美元</li>
                        <li id="allpay">您实际应支付金额为：<span>￥<?php echo number_format($this->money, 2) ?></span> + <span> <?php echo $this->money * 0.03 ?> </span> RMB (手续费) + 0.3 USD (每笔) = <span>$<?php echo $this->PPusd ?></span>美元</li>
                        <li id="partpay" style="display:none">您实际应支付金额为：<span>￥<?php echo number_format($this->money - $this->accountMoney, 2) ?></span> + 3%汇兑手续费:<span> <?php echo ($this->money - $this->accountMoney) * 0.03 ?> </span> RMB = <span>$<?php echo $this->PPpartUsd ?></span>美元</li>
                    </ul>
                </div>
                <div class="payenter">
                    <form id="paypal_form" action="/pay/paypal" method="POST">
                        <input type="hidden" name="paymentType" value='Sale' />
                        <input type="hidden" name="domainId" value="<?php echo $this->id ?>" />
                        <input type="hidden" name="type" value="<?php echo $this->type ?>" />
                        <input type="hidden" class="useAccount" name="useAccount" value="false" />
                        <a id="paypaylink" href="http://www.baidu.com" target="_blank">确认，立即前往支付</a>
                    </form>


                </div>
            </div>

            <div class="chinabank pm" style="display:none;">
                <h4>您当前选择的支付方式是支付宝</h4>
                <div class="pingtai">
                    <ul>
                        <li class="bankON"><a class="p1" href="#">支付宝</a><i></i></li>                    	
                    </ul>
                </div>
                <div class="zhifuNUM">
                    <ul>
                        <li>用支付宝无需手续费，推荐使用</li>
                        <li id="allpay2">您本次支付金额为：<span>￥<?php echo number_format($this->money, 2) ?></span>人民币</li>
                        <li id="partpay2" style="display:none">您实际应支付金额为：<span>￥<?php echo number_format($this->money - $this->accountMoney, 2) ?></span> 人民币</li>
                    </ul>
                </div>

                <div class="payenter">
                    <form id="chinapay_form" action="/pay/chinapay" method="POST">
                        <input type="hidden" value="true" name="paytype" />
                        <input type="hidden" name="domainId" value="<?php echo $this->id ?>" />
                        <input type="hidden" name="type" value="<?php echo $this->type ?>" />
                        <input type="hidden" class="useAccount" name="useAccount" value="false" />
                        <a id="alipaylink" href="javascript:void(0)">确认，立即前往支付</a>
                    </form>
                </div>
            </div>
            <div class="chinabank pm" style="display:none;">
                <div class="modeTS">
                    <h2 style="color:red">请选择您的信用卡类型:</h2>
                </div>
                <div id="card" class="pingtai">
                    <ul>
                        <li><a class="p4" href="javascript:void(0)" data="boc-visa">VISA</a><i></i></li>
                        <li><a class="p5" href="javascript:void(0)" data="boc-master">Master</a><i></i></li>
                        <li><a class="p6" href="javascript:void(0)" data="boc-jcb">JCB</a><i></i></li>
                    </ul>
                </div>
                <div class="zhifuNUM">
                    <ul>
                        <li>国际信用卡汇兑手续费为：4%<i><a href="http://help.uuch.com/?p=325" target="_blank">什么是汇兑手续费？</a></i></li>
                        <li>当前汇率：<?php echo $this->rate ?> 人民币/美元</li>
                        <li id="allpay">您实际应支付金额为：<span>￥<?php echo number_format($this->money, 2) ?></span> + 4%汇兑手续费:<span> <?php echo $this->money * 0.04 ?> </span> RMB = <span id="cardusmoney">$<?php echo $this->CCusd ?></span>美元</li>
                        <li id="partpay" style="display:none">您实际应支付金额为：<span>￥<?php echo number_format($this->money - $this->accountMoney, 2) ?></span> + 4%汇兑手续费:<span> <?php echo ($this->money - $this->accountMoney) * 0.04 ?> </span> RMB = <span>$<?php echo $this->CCpartUsd ?></span>美元</li>
                    </ul>
                </div>
                <div class="payenter">
                    <form id="card_form" action="/pay/card" method="POST">
                        <input type="hidden" name="paymentType" value='Sale' />
                        <input type="hidden" id="vcard" name="card" value="" />
                        <input type="hidden" id="jsreturn" name="jsreturn" value=""/>
                        <input type="hidden" name="domainId" value="<?php echo $this->id ?>" />
                        <input type="hidden" name="type" value="<?php echo $this->type ?>" />
                        <input type="hidden" class="useAccount" name="useAccount" value="false" />
                        <a id="cardlink" href="javascript:void(0)">确认，立即前往支付</a>
                    </form>
                </div>
            </div>
        </div>
        <div class="Completion">
            <p>完成支付后，您可以： <a href="/member/waybill">查看运单状态</a><i>|</i><a href="/member/mystore">返回我的仓库</a></p>
        </div>

    </div>
</div>
<?php
//如果count=1，证明是首次统计，否则不要进入统计了
if($this->count=='1'){
//Google追踪代码，一般的都只算是两元收入
$tid = $this->type.'_' . $this->id;
$country = '';
$money = 2;
$sku = 'U_'.$this->type;
$productName = $this->name;
$category = $productName;
$unitPrice = $this->money;

if($this->type== Application_Model_PayBill::TYPE_WAYBILL){//如果是运单，进行特别统计
$money = $this->money;
$country = $this->payer->CityBy->Name;  //发货国家
$weight = $this->payer->Weight;

$sku = $this->payer->getExpressBy()->Name.'_'. $this->payer->CityBy->Name;  //快递名称+国家名称
$productName = $this->payer->getExpressBy()->Name;  //快递名称+国家名称
$category = $country; //用国家名称进行分类名称，方便统计发的国家
$unitPrice = $money / $weight;

?>
<script type="text/javascript">
    _gaq.push(['_addTrans', '<?= $tid ?>', '<?= $productName ?>', '<?= $money ?>', null, null, null, null, '<?= $country ?>']);
    _gaq.push(['_addItem', '<?= $tid ?>', '<?= $sku ?>', '<?= $productName ?>', '<?= $category ?>', '<?= $unitPrice ?>', '<?= $weight ?>']);
    _gaq.push(['_trackTrans']);
</script>
<?php } 
}
?>